# 一维卷积网络
import torch.nn as nn


class Conv1d(nn.Module):
    def __init__(self, in_seq_len=100, out_seq_len=184):
        super(Conv1d, self).__init__()
        self.in_seq_len = in_seq_len
        self.out_seq_len = out_seq_len

        self.conv1 = nn.Sequential(
            # (b,1,100) -> (b,10,98)
            nn.Conv1d(in_channels=1, out_channels=16, kernel_size=3),
            nn.ReLU(inplace=True),
            # (b,10,98) -> (b,16,49)
            nn.AvgPool1d(2)
        )
        self.conv2 = nn.Sequential(
            # (b,16,49) -> (b,32,48)
            nn.Conv1d(in_channels=16, out_channels=32, kernel_size=2),
            nn.ReLU(inplace=True),
            # (b,32,48) -> (b,32,24)
            nn.AvgPool1d(2)
        )
        self.fc = nn.Sequential(
            nn.Linear(32*24, 512),
            nn.ReLU(inplace=True),
            nn.Linear(512, 256),
            nn.ReLU(inplace=True),
            nn.Linear(256, self.out_seq_len)

        )

    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        x = x.view(x.shape[0], 1, -1)
        out = self.fc(x)
        return out




